package cn.test.livedatademo

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.MutableLiveData

class SecondFragment() : Fragment() {
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        val view = inflater.inflate(R.layout.fragment_second, container, false)
        view.findViewById<View>(R.id.button).setOnClickListener {
            (activity as MainActivity).nameLiveData.value = "第二个Fragment的数据"
        }
        return view
    }
}